//
//  JwDispatch.m
//  JwPack
//
//  Created by 陈警卫 on 2024-08-16.
//

#import "JwDispatch.h"

@implementation JwDispatch

/// 全局异步队列
+ (void)async_global:(void(^)(void))comp {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        comp();
    });
}

/// 异步回主线程
+ (void)async_main:(void(^)(void))comp {
    dispatch_async(dispatch_get_main_queue(), ^{
        comp();
    });
}

/// 回主线程延时执行
+ (void)after_main:(CGFloat)time comp:(void(^)(void))comp {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void){
        comp();
    });
}

@end
